#pragma once

#include <iostream>
#include <vector>
#include <memory>

using namespace  std;

namespace observe{

//观察者
class CObserveBase{
public:
    virtual void update()=0;
    virtual ~CObserveBase(){}
};

//观察者A
class CObserveA : public CObserveBase{
public:
    void update(){
        cout<<"CObserveA"<<endl;
    }
};

//观察者B
class CObserveB : public CObserveBase{
public:
    void update(){
        cout<<"CObserveB"<<endl;
    }
};

//被观察者
class CObserved {
public:
    void add_observe(CObserveBase* observe);
    void remove_observe(CObserveBase* observe);
    ~CObserved();
    void update();
private:
    vector<CObserveBase*> m_observes;
};
}
